<div>
    <div class="row justify-content-center">
        <div class="col-md-4">
            <h1 jhiTranslate="reset.finish.title">Reset password</h1>

            <div *ngIf="initialized && !key" class="alert alert-danger" jhiTranslate="reset.finish.messages.keymissing">
                <strong>The password reset key is missing.</strong>
            </div>

            <div *ngIf="key && !success" class="alert alert-warning">
                <span jhiTranslate="reset.finish.messages.info">Choose a new password</span>
            </div>

            <div *ngIf="error" class="alert alert-danger">
                <span jhiTranslate="reset.finish.messages.error">Your password couldn't be reset. Remember a password request is only valid for 24 hours.</span>
            </div>

            <div *ngIf="success" class="alert alert-success">
                <span jhiTranslate="reset.finish.messages.success"><strong>Your password has been reset.</strong> Please </span>
                <a (click)="login()" class="alert-link" jhiTranslate="global.messages.info.authenticated.link">sign
                    in</a>.
            </div>

            <div *ngIf="doNotMatch" class="alert alert-danger" jhiTranslate="global.messages.error.dontmatch">
                The password and its confirmation do not match!
            </div>

            <div *ngIf="key && !success">
                <form (ngSubmit)="finishReset()" [formGroup]="passwordForm" name="form" role="form">
                    <div class="form-group">
                        <label class="form-control-label" for="newPassword"
                               jhiTranslate="global.form.newpassword.label">New password</label>
                        <input #newPassword class="form-control" formControlName="newPassword" id="newPassword"
                               name="newPassword"
                               placeholder="{{ 'global.form.newpassword.placeholder' | translate }}" type="password">

                        <div *ngIf="passwordForm.get('newPassword')!.invalid && (passwordForm.get('newPassword')!.dirty || passwordForm.get('newPassword')!.touched)">
                            <small *ngIf="passwordForm.get('newPassword')?.errors?.required"
                                   class="form-text text-danger"
                                   jhiTranslate="global.messages.validate.newpassword.required">
                                Your password is required.
                            </small>

                            <small *ngIf="passwordForm.get('newPassword')?.errors?.minlength"
                                   class="form-text text-danger"
                                   jhiTranslate="global.messages.validate.newpassword.minlength">
                                Your password is required to be at least 4 characters.
                            </small>

                            <small *ngIf="passwordForm.get('newPassword')?.errors?.maxlength"
                                   class="form-text text-danger"
                                   jhiTranslate="global.messages.validate.newpassword.maxlength">
                                Your password cannot be longer than 50 characters.
                            </small>
                        </div>

                        <jhi-password-strength-bar
                                [passwordToCheck]="passwordForm.get('newPassword')!.value"></jhi-password-strength-bar>
                    </div>

                    <div class="form-group">
                        <label class="form-control-label" for="confirmPassword"
                               jhiTranslate="global.form.confirmpassword.label">New password confirmation</label>
                        <input class="form-control" formControlName="confirmPassword" id="confirmPassword"
                               name="confirmPassword"
                               placeholder="{{ 'global.form.confirmpassword.placeholder' | translate }}"
                               type="password">

                        <div *ngIf="passwordForm.get('confirmPassword')!.invalid && (passwordForm.get('confirmPassword')!.dirty || passwordForm.get('confirmPassword')!.touched)">
                            <small *ngIf="passwordForm.get('confirmPassword')?.errors?.required"
                                   class="form-text text-danger"
                                   jhiTranslate="global.messages.validate.confirmpassword.required">
                                Your password confirmation is required.
                            </small>

                            <small *ngIf="passwordForm.get('confirmPassword')?.errors?.minlength"
                                   class="form-text text-danger"
                                   jhiTranslate="global.messages.validate.confirmpassword.minlength">
                                Your password confirmation is required to be at least 4 characters.
                            </small>

                            <small *ngIf="passwordForm.get('confirmPassword')?.errors?.maxlength"
                                   class="form-text text-danger"
                                   jhiTranslate="global.messages.validate.confirmpassword.maxlength">
                                Your password confirmation cannot be longer than 50 characters.
                            </small>
                        </div>
                    </div>

                    <button [disabled]="passwordForm.invalid" class="btn btn-primary"
                            jhiTranslate="reset.finish.form.button" type="submit">Reset Password
                    </button>
                </form>
            </div>
        </div>
    </div>
</div>
